/*
 * @Author: liaoyu1992 1519778181@qq.com
 * @Date: 2022-11-03 22:11:06
 * @LastEditors: liaoyu1992 1519778181@qq.com
 * @LastEditTime: 2022-11-09 13:55:44
 * @FilePath: \kgantt\core\types\publicTypes.ts
 * @Description: 公共的type
 */
export enum ViewMode {
  Hour = "Hour",
  QuarterDay = "Quarter Day",
  HalfDay = "Half Day",
  Day = "Day",
  /** ISO-8601 周 */
  Week = "Week",
  Month = "Month",
  Year = "Year",
}
export enum AreaMode {
  Date = "Date",
  Input = "Input"
}
export type TaskType = "task" | "milestone" | "project";
export interface Task {
  id: string;
  type: TaskType;
  name: string;
  start: Date;
  end: Date;
  progress: number;/** 0 到 100 */
  styles?: {
    backgroundColor?: string;
    backgroundSelectedColor?: string;
    progressColor?: string;
    progressSelectedColor?: string;
  };
  isDisabled?: boolean;
  project?: string;
  dependencies?: string[];
  hideChildren?: boolean;
  displayOrder?: number;
  extData?: object;
}
export interface EventOption {
  /**
   * 更新日期的间隔（步长）
   */
  timeStep?: number;
  /**
   * 选中
   */
  onSelect?: (task: Task, isSelected: boolean) => void;
  /**
   * 双击
   */
  onDoubleClick?: (task: Task) => void;
  /**
   * 单击
   */
  onClick?: (task: Task) => void;
  /**
   * 开始时间或者结束时间更改，如果返回false则取消操作
   */
  onDateChange?: (
    task: Task,
    children: Task[]
  ) => void | boolean | Promise<void> | Promise<boolean>;
  /**
   * 进度更改，如果返回false则取消操作
   */
  onProgressChange?: (
    task: Task,
    children: Task[]
  ) => void | boolean | Promise<void> | Promise<boolean>;
  /**
   * 条目删除时调用，如果返回false则取消操作
   */
  onDelete?: (task: Task) => void | boolean | Promise<void> | Promise<boolean>;
  /**
   * 条目展开时调用
   */
  onExpanderClick?: (task: Task) => void;
}
export interface DisplayOption {
  viewMode?: ViewMode;
  viewDate?: Date;
  preStepsCount?: number;
  /**
   * 可选值: ISO 639-2, Java Locale
   */
  locale?: string;
  rtl?: boolean;
}
export interface StylingOption {
  headerHeight?: number;
  listCellWidth?: number;
  listWidth?: string;
  rowHeight?: number;
  ganttHeight?: number;
  barCornerRadius?: number;
  handleWidth?: number;
  fontFamily?: string;
  fontSize?: string;
  /**
   * How many of row width can be taken by task.
   * From 0 to 100
   */
  barFill?: number;
  barProgressColor?: string;
  barProgressSelectedColor?: string;
  barBackgroundColor?: string;
  barBackgroundSelectedColor?: string;
  projectProgressColor?: string;
  projectProgressSelectedColor?: string;
  projectBackgroundColor?: string;
  projectBackgroundSelectedColor?: string;
  milestoneBackgroundColor?: string;
  milestoneBackgroundSelectedColor?: string;
  arrowColor?: string;
  arrowIndent?: number;
  todayColor?: string;
  tooltipContent?: string;
  taskListHeader?: string;
  taskListTable?: string;
}
export interface GanttProps extends EventOption, DisplayOption, StylingOption {
  tasks: Task[];
  resourceArea: ResourceArea[];
  resources: Resource[]
}
export interface ResourceArea {
  fieldId: string;
  name: string;
  type? : AreaMode;
  expand?:boolean
}
export interface Resource {
  fieldId: String;
  value: String
}